﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace WebApplication3
{
    public class DbHelp
    {
        //连接字符串
        private static readonly string Constring = "server=DESKTOP-B0M4KE7;database=CMS;uid=sa;pwd=030824;";

        //查询
        public static DataTable GetData (string sql)
        {
            SqlDataAdapter adapter = new SqlDataAdapter(sql, Constring);
            DataTable data = new DataTable();
            adapter.Fill(data);
            return data;
        }
        //增删改
        public static int  CDU(string sql)
        {
            SqlConnection connection = new SqlConnection(Constring);
            SqlCommand command = new SqlCommand();
            command.CommandText = sql;

            connection.Open();
            var abs = command.ExecuteNonQuery();
            connection.Close();
            return abs;

        }
    }
}